#实验7 （2）
#导包
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By

#反爬
op = webdriver.ChromeOptions()
op.add_experimental_option('excludeSwitches', ['enable-automation'])
op.add_experimental_option('useAutomationExtension', False)

#1）打开MeetHere首页，http://118.121.200.162:8085/index
driver = webdriver.Chrome(options=op)
driver.get("http://118.121.200.162:8085/index")

# 2）点击登录，输入用户名和密码，点击登录
# 3）登录成功后跳转页面，检查用户昵称与预期一致
driver.find_element(By.XPATH,'//*[@id="navbar"]/div/ul/li[1]/a').click()
driver.find_element(By.XPATH,'//*[@id="userID"]').send_keys('明明明')
driver.find_element(By.XPATH,'//*[@id="password"]').send_keys('12345678')
driver.find_element(By.XPATH,'//*[@id="submit"]').click()
sleep(3)
alert = driver.switch_to.alert
print(alert.text)
alert.accept()
sleep(3)

driver.quit()